Attribute VB_Name = "ComFuncs"
Public Fav() As String
Public favtitle() As String
Public searchprefix() As String
Public searchsuffix() As String
Public searchtitle() As String
Public homepage As String
Public searchdefault As Integer
Public addchanged As Boolean
Public searchchanged As Boolean
Public AddHistory() As String
Public SearchWord As String
Public ReadComplete As Boolean
Public LastNavigation() As String
Public proxydefault As Integer
Public AddBarSearchDefault As Integer
Public ShowSearchBox As Boolean
Public ShowStatusBar As Boolean
Public ClosedPageTitles(10) As String
Public ClosedPageURLs(10) As String
Public newTabMode As Integer

Sub ReadConfig()
'====New ReadConfig====
Dim temp As String
Dim count(4) As Integer
Dim readcount(4) As Integer
Open App.Path & "\IE.ini" For Input As #1
While Not EOF(1)
Input #1, temp
If UCase(temp) = "[SETTINGS]" Then countblock = 1
If UCase(temp) = "[FAVORITES]" Then countblock = 2
If UCase(temp) = "[SEARCHENGINES]" Then countblock = 3
count(countblock) = count(countblock) + 1
Wend
Close #1
ReDim favtitle((count(2) - 1) / 2)
ReDim Fav((count(2) - 1) / 2)
ReDim searchprefix((count(3) - 1) / 3)
ReDim searchtitle((count(3) - 1) / 3)
ReDim searchsuffix((count(3) - 1) / 3)
Open App.Path & "\IE.ini" For Input As #1
While Not EOF(1)
Start:
Line Input #1, temp
If UCase(temp) = "[SETTINGS]" Then iniblock = 1: GoTo Start
If UCase(temp) = "[FAVORITES]" Then iniblock = 2: GoTo Start
If UCase(temp) = "[SEARCHENGINES]" Then iniblock = 3: GoTo Start
Select Case iniblock
Case Is = 1
If UCase(Left$(temp, 9)) = "HOMEPAGE=" Then homepage = Right$(temp, Len(temp) - 9)
If UCase(Left$(temp, 20)) = "DEFAULTSEARCHENGINE=" Then searchdefault = CInt(Right$(temp, Len(temp) - 20))
If UCase(Left$(temp, 13)) = "ADDBARSEARCH=" Then AddBarSearchDefault = CInt(Right$(temp, Len(temp) - 13))
If UCase(Left$(temp, 14)) = "SHOWSEARCHBOX=" Then ShowSearchBox = CInt(Right$(temp, Len(temp) - 14))
If UCase(Left$(temp, 14)) = "SHOWSTATUSBAR=" Then ShowStatusBar = CInt(Right$(temp, Len(temp) - 14))
If UCase(Left$(temp, 11)) = "NEWTABMODE=" Then newTabMode = CInt(Right$(temp, Len(temp) - 11))
Case Is = 2
readcount(iniblock) = readcount(iniblock) + 1
If readcount(iniblock) Mod 2 = 1 Then favtitle((readcount(iniblock) + 1) / 2) = temp Else Fav(readcount(iniblock) / 2) = temp
Case Is = 3
readcount(iniblock) = readcount(iniblock) + 1
If readcount(iniblock) Mod 3 = 1 Then
searchtitle((readcount(iniblock) + 2) / 3) = temp
ElseIf readcount(iniblock) Mod 3 = 2 Then
searchprefix((readcount(iniblock) + 1) / 3) = temp
Else
searchsuffix(readcount(iniblock) / 3) = temp
End If
End Select
Wend
Close #1
ReadComplete = True
End Sub

Sub WriteConfig()
Open App.Path & "\IE.ini" For Output As #1
Print #1, "[Settings]"
Print #1, "Homepage=" & homepage
Print #1, "DefaultSearchEngine=" & CStr(searchdefault)
Print #1, "AddBarSearch=" & CStr(AddBarSearchDefault)
Print #1, "ShowSearchBox=" & CStr(-CInt(ShowSearchBox)) 'In order to write 1 for true instead of -1, and 0 remains unchanged
Print #1, "ShowStatusBar=" & CStr(-CInt(ShowStatusBar)) 'In order to write 1 for true instead of -1, and 0 remains unchanged
Print #1, "NewTabMode=" & CStr(newTabMode) '1=show closed pages, 0=show homepage
Print #1, "[Favorites]"
For i = 1 To UBound(Fav)
Print #1, favtitle(i)
Print #1, Fav(i)
Next i
Print #1, "[SearchEngines]"
For i = 1 To UBound(searchtitle)
Print #1, searchtitle(i)
Print #1, searchprefix(i)
Print #1, searchsuffix(i)
Next i
Close #1
End Sub
